package com.s64.ch08.entity;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
public class AjaxResult implements Serializable {
    private int code;
    private String msg;
    private Object data;

    public static AjaxResult ok() {
        return new AjaxResult().setCode(200);
    }

    public static AjaxResult ok(Object data) {
        return new AjaxResult().setCode(200).setData(data);
    }

    public static AjaxResult err() {
        return new AjaxResult().setCode(500);
    }

    public static AjaxResult err(String msg) {
        return new AjaxResult().setCode(500).setMsg(msg);
    }

    public static AjaxResult err(int code, String msg) {
        return new AjaxResult().setMsg(msg).setCode(code);
    }
}
